#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define WLEN_MAX ((int) 1e+6)

int
strcmp_ptr(const void *p1, const void *p2)
{
	return strcmp(* (char * const *) p1, * (char * const *) p2);
}

int
main(void)
{
	int n;
	static char newword[WLEN_MAX];
	char **word_ptr;
	register int i = 0;

	(void) freopen("words.in", "r", stdin);
	(void) freopen("words.out", "w", stdout);

	(void) scanf("%d", &n);
	word_ptr = (char**) malloc(n * sizeof(char*));
	for (i = 0 ; i < n ; ++i) {
		(void) scanf("%s", newword);
		word_ptr[i] = (char*) malloc((size_t)(strlen(newword) + 1));
		if (word_ptr[i] == NULL) {
			(void) fprintf(stderr, "Failed to allocate %zu bytes\n",
					strlen(newword) + 1);
			return 1;
		}
		strcpy(word_ptr[i], newword);
	}

	qsort(word_ptr, (size_t) n, sizeof (char*), strcmp_ptr);

	for (i = 0 ; i < n ; ++i) {
		printf("%s\n", word_ptr[i]);
		free(word_ptr[i]);
	}
	free(word_ptr);
	return (0);
}
